package com.ftg.learn.mall.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.learn.mall.entity.PmsProductAttributeCategory;
import com.ftg.learn.mall.service.IPmsProductAttributeCategoryService;
import com.ftg.learn.util.ResEntity;
import com.ftg.learn.util.ResPageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 产品属性分类表 前端控制器
 * </p>
 *
 * @author mallCommon
 * @since 2022-04-19
 */
@RestController
@RequestMapping("/mall/pmsProductAttributeCategory")
public class PmsProductAttributeCategoryController {

    @Autowired
    IPmsProductAttributeCategoryService categoryService;

    /**
     * 分页获取所有商品属性分类
     */
    @GetMapping("/findAllAndPage")
    public ResPageEntity findAllAndPage(@RequestParam int page,@RequestParam int limit){
        Page<PmsProductAttributeCategory> p = new Page<>(page,limit);
        p.setRecords(categoryService.findAllAndPage(p));
        return new ResPageEntity(p);
    }

    /**
     * 获取单个商品属性分类信息
     */
    @GetMapping("/findById")
    public ResEntity findById(@RequestParam Long id){
        return new ResEntity(0,"success",categoryService.findById(id));
    }

}
